include io.asm

stack segment stack
	dw 128 dup (?)
stack ends

;;======================================================================
data segment
	Head db "Vasilenko Anatoly. Group 111.$"
	Input db "Enter please sequence: $"
	Output db "Answer: $"
data ends
;;======================================================================

code segment 'code'
	assume ss:stack, ds:data, cs:code
start:
	mov ax,data
	mov ds,ax
	lea dx, Head
	outstr
	newline
	newline
	;;------------------------------------------------------------------
		lea dx, Input;
		outstr;
		
		mov si, 0; answer
		mov ch, 0;
		
		L1:	inch cl;
			mov sp, cx; first letter
			mov di, cx; last letter
			
			L2:	inch cl;
				cmp cl, ',';
				je short continue_L2;
				cmp cl, '.';
				je short continue_L2;
				mov di, cx;
			jmp L2;
			
		continue_L2:
			cmp sp, di;
			jne next_1
			inc si;
			
		next_1:
			cmp cl, '.'
		jne L1;
		
		lea dx, Output;
		outstr;
		outword si
	;;------------------------------------------------------------------

the_end:
	newline;
	newline;
	mov ah,8
	int 21h
    finish
code ends

;;======================================================================
end start 

;;======================================================================
